﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcAppDemo.Models.Dinner>" %>

<asp:Content ID="Title" ContentPlaceHolderID="TitleContent" runat="server">
    Dinner:
    <%=Html.Encode(Model.Title) %>
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="MainContent" runat="server">
    <div id="dinnerDiv">
        <h2>
            <%=Html.Encode(Model.Title) %></h2>
        <p>
            <strong>When:</strong>
            <%=Model.EventDate.ToShortDateString() %>
            <strong>@</strong>
            <%=Model.EventDate.ToShortTimeString() %>
        </p>
        <p>
            <strong>Where:</strong>
            <%=Html.Encode(Model.Address) %>,
            <%=Html.Encode(Model.Country) %>
        </p>
        <p>
            <strong>Description:</strong>
            <%=Html.Encode(Model.Description) %>
        </p>
        <p>
            <strong>Organizer:</strong>
            <%=Html.Encode(Model.HostedBy) %>
            (<%=Html.Encode(Model.ContactPhone) %>)
        </p>
        <script type="text/javascript">

            function AnimateRSVPMessage() {
                $("#rsvpmsg").animate({ fontSize: "1.5em" }, 400);
            } 
        </script>
        <div id="rsvpmsg" class="notice-normal">
            <% if (Request.IsAuthenticated)
               { %>
            <% if (Model.IsUserRegistered(Context.User.Identity.Name))
               { %>
            You are registred for this event!
            <% }
               else
               { %>
            <%= Ajax.ActionLink( "RSVP for this event",
                                 "Register", "RSVP",
                                  new { id=Model.DinnerID },
                                  new AjaxOptions { UpdateTargetId="rsvpmsg",
                                                    OnSuccess = "AnimateRSVPMessage"
                                  }) %>
            <% } %>
            <% }
               else
               { %>
            <p>
                <a href="/Account/Logon">Logon</a> to RSVP for this event.</p>
            <% } %>
        </div>
        <div>
            <%= Html.ActionLink("Edit Dinner", "Edit", new { id=Model.DinnerID })%>
            |
            <%= Html.ActionLink("Delete Dinner","Delete", new { id=Model.DinnerID})%>
            |
            <%= Html.ActionLink("Back off","Index", "Dinners")%>
        </div>
    </div>
    <div id="mapDiv">
        <%Html.RenderPartial("map"); %>
    </div>
</asp:Content>
